
let rec min_nodes h =
  if h <= 0 then 0 
  else if h = 1 then 1
  else min_nodes (h - 1) + min_nodes (h - 2) + 1;;

let rec min_nodes_loop m0 m1 h =
    if h <= 1 then m1
    else min_nodes_loop m1 (m1 + m0 + 1) (h - 1)

let min_nodes h =
    if h <= 0 then 0 else min_nodes_loop 0 1 h
;;

let max_nodes h = 1 lsl h - 1;;